//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace OpenLS.Drawing.UI.Internals
{
    internal class ThemeToGroupedFontsConverter : IValueConverter
    {
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var theme = StrictConverter.Convert<Theme>(value);
            if (value == null)
                return Fonts.SystemFontFamilies;
            var result = new List<object>
                             {
                                 FontFamilyGroup.Theme,
                                 theme.FontScheme.MinorFont.Latin,
                                 theme.FontScheme.MajorFont.Latin,
                                 FontFamilyGroup.Standard
                             };

            foreach (var f in Fonts.SystemFontFamilies)
            {
                if (f.Source == theme.FontScheme.MajorFont.Latin.Source)
                    continue;
                if (f.Source == theme.FontScheme.MinorFont.Latin.Source)
                    continue;
                result.Add(f);
            }
            return result;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
        #endregion
    }
}